import { Request_API_CN } from '../utils/index.js'
import { APP_ID, APP_SECRET } from './config.js'


export default () => {
  return new Promise((resolve, reject) => {
    wx.login({
      success: (res) => {
        // console.log(res)
        let code = res.code
        let data = {
          appid: APP_ID,
          secret: APP_SECRET,
          code: res.code
        }
        // console.log(res)
        Request_API_CN('/currency/getopenid', 'POST', data)
          .then((res) => {
            if (res.data.data.openid) resolve(res)
          })
      }
    })
  })
}